package com.cityeye.form;

import com.cityeye.dao.DepartmentDao;
import com.cityeye.entity.Department;
import com.cityeye.entity.Patrol;

public class PatrolForm extends AbsEntityForm<Patrol> {

	// Fields
	private Integer id;
	private Integer departmentId;
	private String name;
	private String mobile="";
	private String homephone="";
	private String mobile2;
	private Integer age;
	private Integer gender=1;
	private String addr="";

	// Property accessors
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getDepartmentId() {
		return this.departmentId;
	}

	public void setDepartmentId(Integer department) {
		this.departmentId = department;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getHomephone() {
		return this.homephone;
	}

	public void setHomephone(String homephone) {
		this.homephone = homephone;
	}

	public String getMobile2() {
		return this.mobile2;
	}

	public void setMobile2(String mobile2) {
		this.mobile2 = mobile2;
	}

	public Integer getAge() {
		return this.age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Integer getGender() {
		return this.gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public String getAddr() {
		return this.addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}
	
	public Patrol toEntity(){
		Patrol patrol = new Patrol();
		patrol.setId(getId());
		patrol.setName(getName());		
		patrol.setAddr(getAddr());	
		patrol.setAge(getAge());
		patrol.setGender(getGender());
		patrol.setHomephone(getHomephone());		
		patrol.setMobile(getMobile());	
		patrol.setMobile2(getMobile2());
		
		Department parent_dept=null;
		if(getDepartmentId()!=null){
			DepartmentDao deptDao = new DepartmentDao();		
			parent_dept = deptDao.findById(getDepartmentId());
		}
		
		patrol.setDepartment(parent_dept);		
		
		return patrol;
	}	
}
